package configuration.dataObjects
{
	import common.utils.DateManager;
	
	import mx.collections.ArrayCollection;
	
	[Bindable]
	public class UserDO
	{
		public var INTERNAL_USER_NUM:Number = 0;
		public var USER_ID:String = "";
		public var DESCRIPTION:String = "";
		public var DEPARTMENT:String = "";
		public var ACTIVE:String = "";
		public var USER_STAMP:String = "";
		public var DATE_TIME_STAMP:String = DateManager.GetTodayString();
		public var DEFAULT_WHS:String = "";
		public var DEFAULT_RECV_PREF:String = "";
		public var DEFAULT_SHIP_PREF:String = "";
		public var DEFAULT_TASK_PREF:String = "";

		public function UserDO():void
		{
		}

		public function Init(xmlObj:XML):void{
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {			
					this[itemProp.name()] = itemProp;
				}
			}
		}
		
		public function ToXML():XML{
			var xmlObj:XML =
			<USER>
				<INTERNAL_USER_NUM>{INTERNAL_USER_NUM}</INTERNAL_USER_NUM>
				<USER_ID>{USER_ID}</USER_ID>
				<DESCRIPTION>{DESCRIPTION}</DESCRIPTION>
				<DEPARTMENT>{DEPARTMENT}</DEPARTMENT>
				<ACTIVE>{ACTIVE}</ACTIVE>
				<USER_STAMP>{USER_STAMP}</USER_STAMP>
				<DATE_TIME_STAMP>{DATE_TIME_STAMP}</DATE_TIME_STAMP>
				<DEFAULT_WHS>{DEFAULT_WHS}</DEFAULT_WHS>		
				<DEFAULT_RECV_PREF>{DEFAULT_RECV_PREF}</DEFAULT_RECV_PREF>		
				<DEFAULT_SHIP_PREF>{DEFAULT_SHIP_PREF}</DEFAULT_SHIP_PREF>		
				<DEFAULT_TASK_PREF>{DEFAULT_TASK_PREF}</DEFAULT_TASK_PREF>		
			</USER>;
			return xmlObj;
		}
		
		public static function getItems(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var itm:UserDO = new UserDO();
				itm.Init(xml);
				ac.addItem(itm);
			}
			return ac;
		}

	}
}